import {Component, Input, OnInit} from '@angular/core';
import {HttpService} from '../http.service';
import {ActivatedRoute, Router} from '@angular/router';
import { CourseInfo} from '../student';
import {Location} from '@angular/common';

@Component({
  selector: 'app-course-detail',
  templateUrl: './course-detail.component.html',
  styleUrls: ['./course-detail.component.css']
})
export class CourseDetailComponent implements OnInit {
  CourseDetail: CourseInfo = {
    courseid : '',
    coursename: '',
    credit : null ,
    type : '',
  };
  constructor( private httpService: HttpService,
               private route: ActivatedRoute,
               private location: Location, ) { }

  courseid: string = String(this.route.snapshot.paramMap.get('courseid'));
  loading = true;
  size = 'default';
  getCourseDetail() {
    // @ts-ignore
    this.httpService.getCourseDetail(this.courseid).subscribe(
      res => this.CourseDetail = {
        courseid : res.data.courseid,
        coursename: res.data.coursename,
        credit : res.data.credit,
        type : res.data.type
      });
    console.log('获取信息成功');
    this.loading = false;
  }

  goBack(): void {
    this.location.back()
  }
  ngOnInit(): void {
    this.getCourseDetail()
  }
}
